Convert GailToggleButton to GtkToggleButtonAccessible
authorMatthias Clasen <mclasen@redhat.com>
Tue, 28 Jun 2011 04:53:22 +0000 (00:53 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 5 Jul 2011 20:08:54 +0000 (16:08 -0400)
gtk/a11y/Makefile.am
gtk/a11y/gail.c
gtk/a11y/gailtogglebutton.c [deleted file]
gtk/a11y/gailtogglebutton.h [deleted file]
gtk/a11y/gtkradiobuttonaccessible.c
gtk/a11y/gtkradiobuttonaccessible.h
gtk/a11y/gtktogglebuttonaccessible.c [new file with mode: 0644]
gtk/a11y/gtktogglebuttonaccessible.h [new file with mode: 0644]
gtk/gtktogglebutton.c

index b13084edb85e27cd103d127674ef7009a4ce223b..deab12cde8626dc0354d8695f12780b48d7136f1 100644 (file)
@@ -45,7 +45,7 @@ gail_c_sources =                      \
        gailtextcell.c                  \
        gailtextutil.c                  \
        gtktextviewaccessible.c         \
-       gailtogglebutton.c              \
+       gtktogglebuttonaccessible.c     \
        gailtoplevel.c                  \
        gailtreeview.c                  \
        gailutil.c                      \
@@ -96,7 +96,7 @@ gail_private_h_sources =              \
        gailtextcell.h                  \
        gailtextutil.h                  \
        gtktextviewaccessible.h         \
-       gailtogglebutton.h              \
+       gtktogglebuttonaccessible.h     \
        gailtoplevel.h                  \
        gailtreeview.h                  \
        gailutil.h                      \
index 165bc365edf64a6a230d31c5ff0ec6daea90c902..0d13b2fdde55bcf6c63010a07d91e308e15d897e 100644 (file)
@@ -42,7 +42,6 @@
 #include "gailscrolledwindow.h"
 #include "gailstatusbar.h"
 #include "gailtextcell.h"
-#include "gailtogglebutton.h"
 #include "gailtoplevel.h"
 #include "gailtreeview.h"
 #include "gailutil.h"
@@ -99,7 +98,6 @@ GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_WIDGET, GailWidget, gail_widget, GTK_TYPE_WIDG
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_CONTAINER, GailContainer, gail_container, GTK_TYPE_CONTAINER)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_BUTTON, GailButton, gail_button, GTK_TYPE_BUTTON)
 GAIL_IMPLEMENT_FACTORY_WITH_FUNC (GAIL_TYPE_MENU_ITEM, GailMenuItem, gail_menu_item, gail_menu_item_new)
-GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_TOGGLE_BUTTON, GailToggleButton, gail_toggle_button, GTK_TYPE_TOGGLE_BUTTON)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_COMBO_BOX, GailComboBox, gail_combo_box, GTK_TYPE_COMBO_BOX)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_MENU_SHELL, GailMenuShell, gail_menu_shell, GTK_TYPE_MENU_SHELL)
 GAIL_IMPLEMENT_FACTORY (GAIL_TYPE_MENU, GailMenu, gail_menu, GTK_TYPE_MENU)
@@ -860,7 +858,6 @@ gail_accessibility_module_init (void)
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_CONTAINER, gail_container);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_BUTTON, gail_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU_ITEM, gail_menu_item);
-  GAIL_WIDGET_SET_FACTORY (GTK_TYPE_TOGGLE_BUTTON, gail_toggle_button);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_COMBO_BOX, gail_combo_box);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU_BAR, gail_menu_shell);
   GAIL_WIDGET_SET_FACTORY (GTK_TYPE_MENU, gail_menu);
diff --git a/gtk/a11y/gailtogglebutton.c b/gtk/a11y/gailtogglebutton.c
deleted file mode 100644 (file)
index 63f8d44..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <string.h>
-#include <gtk/gtk.h>
-#include "gailtogglebutton.h"
-
-static void      gail_toggle_button_class_init        (GailToggleButtonClass *klass);
-
-static void      gail_toggle_button_init              (GailToggleButton      *button);
-
-static void      gail_toggle_button_toggled_gtk       (GtkWidget             *widget);
-
-static void      gail_toggle_button_real_notify_gtk   (GObject               *obj,
-                                                       GParamSpec            *pspec);
-
-static void      gail_toggle_button_real_initialize   (AtkObject             *obj,
-                                                       gpointer              data);
-
-static AtkStateSet* gail_toggle_button_ref_state_set  (AtkObject             *accessible);
-
-G_DEFINE_TYPE (GailToggleButton, gail_toggle_button, GAIL_TYPE_BUTTON)
-
-static void
-gail_toggle_button_class_init (GailToggleButtonClass *klass)
-{
-  GailWidgetClass *widget_class;
-  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
-
-  widget_class = (GailWidgetClass*)klass;
-  widget_class->notify_gtk = gail_toggle_button_real_notify_gtk;
-
-  class->ref_state_set = gail_toggle_button_ref_state_set;
-  class->initialize = gail_toggle_button_real_initialize;
-}
-
-static void
-gail_toggle_button_init (GailToggleButton *button)
-{
-}
-
-static void
-gail_toggle_button_real_initialize (AtkObject *obj,
-                                    gpointer  data)
-{
-  ATK_OBJECT_CLASS (gail_toggle_button_parent_class)->initialize (obj, data);
-
-  g_signal_connect (data,
-                    "toggled",
-                    G_CALLBACK (gail_toggle_button_toggled_gtk),
-                    NULL);
-
-  if (GTK_IS_CHECK_BUTTON (data))
-    obj->role = ATK_ROLE_CHECK_BOX;
-  else
-    obj->role = ATK_ROLE_TOGGLE_BUTTON;
-}
-
-static void
-gail_toggle_button_toggled_gtk (GtkWidget       *widget)
-{
-  AtkObject *accessible;
-  GtkToggleButton *toggle_button;
-
-  toggle_button = GTK_TOGGLE_BUTTON (widget);
-
-  accessible = gtk_widget_get_accessible (widget);
-  atk_object_notify_state_change (accessible, ATK_STATE_CHECKED, 
-                                  gtk_toggle_button_get_active (toggle_button));
-} 
-
-static AtkStateSet*
-gail_toggle_button_ref_state_set (AtkObject *accessible)
-{
-  AtkStateSet *state_set;
-  GtkToggleButton *toggle_button;
-  GtkWidget *widget;
-
-  state_set = ATK_OBJECT_CLASS (gail_toggle_button_parent_class)->ref_state_set (accessible);
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
-  if (widget == NULL)
-    return state_set;
-
-  toggle_button = GTK_TOGGLE_BUTTON (widget);
-
-  if (gtk_toggle_button_get_active (toggle_button))
-    atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
-
-  if (gtk_toggle_button_get_inconsistent (toggle_button))
-    {
-      atk_state_set_remove_state (state_set, ATK_STATE_ENABLED);
-      atk_state_set_add_state (state_set, ATK_STATE_INDETERMINATE);
-    }
-  return state_set;
-}
-
-static void
-gail_toggle_button_real_notify_gtk (GObject           *obj,
-                                    GParamSpec        *pspec)
-{
-  GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (obj);
-  AtkObject *atk_obj;
-  gboolean sensitive;
-  gboolean inconsistent;
-
-  atk_obj = gtk_widget_get_accessible (GTK_WIDGET (toggle_button));
-  sensitive = gtk_widget_get_sensitive (GTK_WIDGET (toggle_button));
-  inconsistent = gtk_toggle_button_get_inconsistent (toggle_button);
-
-  if (strcmp (pspec->name, "inconsistent") == 0)
-    {
-      atk_object_notify_state_change (atk_obj, ATK_STATE_INDETERMINATE, inconsistent);
-      atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
-    }
-  else if (strcmp (pspec->name, "sensitive") == 0)
-    {
-      /* Need to override gailwidget behavior of notifying for ENABLED */
-      atk_object_notify_state_change (atk_obj, ATK_STATE_SENSITIVE, sensitive);
-      atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
-    }
-  else
-    GAIL_WIDGET_CLASS (gail_toggle_button_parent_class)->notify_gtk (obj, pspec);
-}
diff --git a/gtk/a11y/gailtogglebutton.h b/gtk/a11y/gailtogglebutton.h
deleted file mode 100644 (file)
index 6fe9df1..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* GAIL - The GNOME Accessibility Implementation Library
- * Copyright 2001 Sun Microsystems Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GAIL_TOGGLE_BUTTON_H__
-#define __GAIL_TOGGLE_BUTTON_H__
-
-#include "gailbutton.h"
-
-G_BEGIN_DECLS
-
-#define GAIL_TYPE_TOGGLE_BUTTON              (gail_toggle_button_get_type ())
-#define GAIL_TOGGLE_BUTTON(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAIL_TYPE_TOGGLE_BUTTON, GailToggleButton))
-#define GAIL_TOGGLE_BUTTON_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GAIL_TYPE_TOGGLE_BUTTON, GailToggleButtonClass))
-#define GAIL_IS_TOGGLE_BUTTON(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAIL_TYPE_TOGGLE_BUTTON))
-#define GAIL_IS_TOGGLE_BUTTON_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIL_TYPE_TOGGLE_BUTTON))
-#define GAIL_TOGGLE_BUTTON_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIL_TYPE_TOGGLE_BUTTON, GailToggleButtonClass))
-
-typedef struct _GailToggleButton              GailToggleButton;
-typedef struct _GailToggleButtonClass         GailToggleButtonClass;
-
-struct _GailToggleButton
-{
-  GailButton parent;
-};
-
-GType gail_toggle_button_get_type (void);
-
-struct _GailToggleButtonClass
-{
-  GailButtonClass parent_class;
-};
-
-G_END_DECLS
-
-#endif /* __GAIL_TOGGLE_BUTTON_H__ */
index 50e99b37f9b361d6a411d4a60ca47b97e310b17f..b38cb95f6ef15cd5acb23b4a2f9a9fa7ae9b7790 100644 (file)
@@ -23,7 +23,7 @@
 #include "gtkradiobuttonaccessible.h"
 
 
-G_DEFINE_TYPE (GtkRadioButtonAccessible, gtk_radio_button_accessible, GAIL_TYPE_TOGGLE_BUTTON)
+G_DEFINE_TYPE (GtkRadioButtonAccessible, gtk_radio_button_accessible, GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE)
 
 static void
 gtk_radio_button_accessible_initialize (AtkObject *accessible,
index 44f47c54e379612ea9eb9ee4cff9cfc0b18919da..8caa6d2ef794410e001e3cc526322207e7a467d8 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef __GTK_RADIO_BUTTON_ACCESSIBLE_H__
 #define __GTK_RADIO_BUTTON_ACCESSIBLE_H__
 
-#include "gailtogglebutton.h"
+#include "gtktogglebuttonaccessible.h"
 
 G_BEGIN_DECLS
 
@@ -36,14 +36,14 @@ typedef struct _GtkRadioButtonAccessibleClass GtkRadioButtonAccessibleClass;
 
 struct _GtkRadioButtonAccessible
 {
-  GailToggleButton parent;
+  GtkToggleButtonAccessible parent;
 
   GSList *old_group;
 };
 
 struct _GtkRadioButtonAccessibleClass
 {
-  GailToggleButtonClass parent_class;
+  GtkToggleButtonAccessibleClass parent_class;
 };
 
 GType gtk_radio_button_accessible_get_type (void);
diff --git a/gtk/a11y/gtktogglebuttonaccessible.c b/gtk/a11y/gtktogglebuttonaccessible.c
new file mode 100644 (file)
index 0000000..04322f6
--- /dev/null
@@ -0,0 +1,127 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include "gtktogglebuttonaccessible.h"
+
+
+G_DEFINE_TYPE (GtkToggleButtonAccessible, gtk_toggle_button_accessible, GAIL_TYPE_BUTTON)
+
+static void
+gtk_toggle_button_accessible_toggled (GtkWidget *widget)
+{
+  AtkObject *accessible;
+  GtkToggleButton *toggle_button;
+
+  toggle_button = GTK_TOGGLE_BUTTON (widget);
+
+  accessible = gtk_widget_get_accessible (widget);
+  atk_object_notify_state_change (accessible, ATK_STATE_CHECKED,
+                                  gtk_toggle_button_get_active (toggle_button));
+}
+
+static void
+gtk_toggle_button_accessible_initialize (AtkObject *obj,
+                                         gpointer   data)
+{
+  ATK_OBJECT_CLASS (gtk_toggle_button_accessible_parent_class)->initialize (obj, data);
+
+  g_signal_connect (data, "toggled",
+                    G_CALLBACK (gtk_toggle_button_accessible_toggled), NULL);
+
+  if (GTK_IS_CHECK_BUTTON (data))
+    obj->role = ATK_ROLE_CHECK_BOX;
+  else
+    obj->role = ATK_ROLE_TOGGLE_BUTTON;
+}
+
+static void
+gtk_toggle_button_accessible_notify_gtk (GObject    *obj,
+                                         GParamSpec *pspec)
+{
+  GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (obj);
+  AtkObject *atk_obj;
+  gboolean sensitive;
+  gboolean inconsistent;
+
+  atk_obj = gtk_widget_get_accessible (GTK_WIDGET (toggle_button));
+  sensitive = gtk_widget_get_sensitive (GTK_WIDGET (toggle_button));
+  inconsistent = gtk_toggle_button_get_inconsistent (toggle_button);
+
+  if (strcmp (pspec->name, "inconsistent") == 0)
+    {
+      atk_object_notify_state_change (atk_obj, ATK_STATE_INDETERMINATE, inconsistent);
+      atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
+    }
+  else if (strcmp (pspec->name, "sensitive") == 0)
+    {
+      /* Need to override gailwidget behavior of notifying for ENABLED */
+      atk_object_notify_state_change (atk_obj, ATK_STATE_SENSITIVE, sensitive);
+      atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, (sensitive && !inconsistent));
+    }
+  else
+    GAIL_WIDGET_CLASS (gtk_toggle_button_accessible_parent_class)->notify_gtk (obj, pspec);
+}
+
+static AtkStateSet*
+gtk_toggle_button_accessible_ref_state_set (AtkObject *accessible)
+{
+  AtkStateSet *state_set;
+  GtkToggleButton *toggle_button;
+  GtkWidget *widget;
+
+  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
+  if (widget == NULL)
+    return NULL;
+
+  state_set = ATK_OBJECT_CLASS (gtk_toggle_button_accessible_parent_class)->ref_state_set (accessible);
+  toggle_button = GTK_TOGGLE_BUTTON (widget);
+
+  if (gtk_toggle_button_get_active (toggle_button))
+    atk_state_set_add_state (state_set, ATK_STATE_CHECKED);
+
+  if (gtk_toggle_button_get_inconsistent (toggle_button))
+    {
+      atk_state_set_remove_state (state_set, ATK_STATE_ENABLED);
+      atk_state_set_add_state (state_set, ATK_STATE_INDETERMINATE);
+    }
+
+  return state_set;
+}
+
+static void
+gtk_toggle_button_accessible_class_init (GtkToggleButtonAccessibleClass *klass)
+{
+  GailWidgetClass *widget_class;
+  AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+
+  widget_class = (GailWidgetClass*)klass;
+  widget_class->notify_gtk = gtk_toggle_button_accessible_notify_gtk;
+
+  class->ref_state_set = gtk_toggle_button_accessible_ref_state_set;
+  class->initialize = gtk_toggle_button_accessible_initialize;
+}
+
+static void
+gtk_toggle_button_accessible_init (GtkToggleButtonAccessible *button)
+{
+}
diff --git a/gtk/a11y/gtktogglebuttonaccessible.h b/gtk/a11y/gtktogglebuttonaccessible.h
new file mode 100644 (file)
index 0000000..0159cfc
--- /dev/null
@@ -0,0 +1,51 @@
+/* GAIL - The GNOME Accessibility Implementation Library
+ * Copyright 2001 Sun Microsystems Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GTK_TOGGLE_BUTTON_ACCESSIBLE_H__
+#define __GTK_TOGGLE_BUTTON_ACCESSIBLE_H__
+
+#include "gailbutton.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE              (gtk_toggle_button_accessible_get_type ())
+#define GTK_TOGGLE_BUTTON_ACCESSIBLE(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE, GtkToggleButtonAccessible))
+#define GTK_TOGGLE_BUTTON_ACCESSIBLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE, GtkToggleButtonAccessibleClass))
+#define GTK_IS_TOGGLE_BUTTON_ACCESSIBLE(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE))
+#define GTK_IS_TOGGLE_BUTTON_ACCESSIBLE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE))
+#define GTK_TOGGLE_BUTTON_ACCESSIBLE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE, GtkToggleButtonAccessibleClass))
+
+typedef struct _GtkToggleButtonAccessible      GtkToggleButtonAccessible;
+typedef struct _GtkToggleButtonAccessibleClass GtkToggleButtonAccessibleClass;
+
+struct _GtkToggleButtonAccessible
+{
+  GailButton parent;
+};
+
+struct _GtkToggleButtonAccessibleClass
+{
+  GailButtonClass parent_class;
+};
+
+GType gtk_toggle_button_accessible_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GTK_TOGGLE_BUTTON_ACCESSIBLE_H__ */
index 586b7351ee0d3de2269b22e5c9e5a353a08e31d3..3b1a0ada33269e0a0e60f369d9be2b06da5eab49 100644 (file)
@@ -36,6 +36,7 @@
 #include "gtkactivatable.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
+#include "a11y/gtktogglebuttonaccessible.h"
 
 
 /**
@@ -212,6 +213,8 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
                  G_TYPE_NONE, 0);
 
   g_type_class_add_private (class, sizeof (GtkToggleButtonPrivate));
+
+  gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE);
 }
 
 static void